﻿Public Class Form3

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        TableLayoutPanel2.Visible = True
        Panel2.Visible = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Panel2.Visible = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If (SolvingBox.SelectedItem = Nothing) Then
            Me.Close()
        Else
            Me.Hide()
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If (SolvingBox.SelectedItem = Nothing) Then
            Me.Close()
        Else
            Me.Hide()
        End If

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        ColorDialog1.ShowDialog()

        If (ColorDialog1.Color = Color.White) Then
            Button5.BackColor = Color.White
            Main.AnswerBox.ForeColor = Color.White
        ElseIf (ColorDialog1.Color = Color.Red) Then
            Button5.BackColor = Color.Red
            Main.AnswerBox.ForeColor = Color.Red
        ElseIf (ColorDialog1.Color = Color.Yellow) Then
            Button5.BackColor = Color.Yellow
            Main.AnswerBox.ForeColor = Color.Yellow
        ElseIf (ColorDialog1.Color = Color.Blue) Then
            Button5.BackColor = Color.Blue
            Main.AnswerBox.ForeColor = Color.Blue
        Else
            Button5.BackColor = Color.White
            Main.Label11.ForeColor = Color.White
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        If (SolvingBox.SelectedItem = Nothing) Then
            MessageBox.Show("Please select the subject of formular next to the *Solving box.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        ElseIf (Not Main.ComboBox1.SelectedItem = SolvingBox.SelectedItem) Then
            ErrorProvider1.SetError(SolvingBox, "Subject formulars mismatch. >>> Please check if what you selected in *Solving and the Solving box in main Trigsoft window do match.")

        ElseIf (SolvingBox.SelectedItem.Equals("SideX") And Main.ComboBox1.SelectedItem = "SideX") Then
            ErrorProvider1.Clear()
            ProgressBar1n.Visible = False

            For I As Integer = 0 To 1000
                ProgressBar1n.Visible = True
                ProgressBar1n.Increment(I)
                Label3.Text = I.ToString

                If (ProgressBar1n.Value = 1000) Then
                    ProgressBar1n.Visible = False
                End If

                Main.NumericUpDown2.Visible = True
                Main.NumericUpDown1.Enabled = True
                Main.Label6.Text = "Sin<A>:"
                Main.Label4.Text = "Sin<B>:"
                Main.SideYBox.Enabled = True
                Main.SideXBox.Enabled = False
                Main.Clear.Enabled = True

            Next I
            ProgressBar1n.Value = 0
            Me.Hide()
            Label3.Text = "Ready"

            If (ColorDialog1.Color = Color.Black) Then
                Main.Label11.ForeColor = Color.Black
            ElseIf (ColorDialog1.Color = Color.Yellow) Then
                Main.Label11.ForeColor = Color.Yellow
            ElseIf (ColorDialog1.Color = Color.Red) Then
                Main.Label11.ForeColor = Color.Red
            Else
                Main.AnswerBox.ForeColor = Color.White
            End If

        ElseIf (SolvingBox.SelectedItem.Equals("AngleX") And Main.ComboBox1.SelectedItem = "AngleX") Then
            ErrorProvider1.Clear()
            ProgressBar1n.Visible = False

            For I As Integer = 0 To 1000
                ProgressBar1n.Visible = True
                ProgressBar1n.Increment(I)
                Label3.Text = I.ToString

                If (ProgressBar1n.Value = 1000) Then
                    ProgressBar1n.Visible = False
                End If

                Main.NumericUpDown2.Enabled = False
                Main.NumericUpDown2.Visible = True
                Main.NumericUpDown1.Enabled = True
                Main.Label6.Text = "Sine<A>:"
                Main.Label4.Text = "Sine<B>:"
                Main.SideXBox.Enabled = True
                Main.SideYBox.Enabled = True
                Main.Clear.Enabled = True

            Next I
            ProgressBar1n.Value = 0
            Me.Hide()
            Label3.Text = "Ready"

            If (ColorDialog1.Color = Color.Black) Then
                Main.AnswerBox.ForeColor = Color.Black
            ElseIf (ColorDialog1.Color = Color.Yellow) Then
                Main.AnswerBox.ForeColor = Color.Yellow
            ElseIf (ColorDialog1.Color = Color.Red) Then
                Main.AnswerBox.ForeColor = Color.Red
            Else
                Main.AnswerBox.ForeColor = Color.White
            End If

        ElseIf (SolvingBox.SelectedItem = "AngleY") And (Main.ComboBox1.SelectedItem = "AngleY") Then
            ErrorProvider1.Clear()
            ProgressBar1n.Visible = False

            For I As Integer = 0 To 1000
                ProgressBar1n.Visible = True
                ProgressBar1n.Increment(I)
                Label3.Text = I.ToString

                If (ProgressBar1n.Value = 1000) Then
                    ProgressBar1n.Visible = False
                End If

                Main.NumericUpDown2.Visible = True
                Main.NumericUpDown2.Enabled = True
                Main.NumericUpDown1.Enabled = False
                Main.SideXBox.Enabled = True
                Main.Label6.Text = "Sin<A>:"
                Main.Label4.Text = "Sin<B>:"
                Main.SideYBox.Enabled = True
                Main.Clear.Enabled = True

            Next I
            ProgressBar1n.Value = 0
            ProgressBar1n.Visible = False
            Me.Hide()
            Label3.Text = "Ready"

            If (ColorDialog1.Color = Color.Black) Then
                Main.AnswerBox.ForeColor = Color.Black
            ElseIf (ColorDialog1.Color = Color.Yellow) Then
                Main.AnswerBox.ForeColor = Color.Yellow
            ElseIf (ColorDialog1.Color = Color.Red) Then
                Main.AnswerBox.ForeColor = Color.Red
            Else
                Main.AnswerBox.ForeColor = Color.White
            End If

        ElseIf (SolvingBox.SelectedItem = "SideY") And (Main.ComboBox1.SelectedItem = "SideY") Then
            ErrorProvider1.Clear()
            ProgressBar1n.Visible = False

            For I As Integer = 0 To 1000
                ProgressBar1n.Visible = True
                ProgressBar1n.Increment(I)
                Label3.Text = I.ToString

                If (ProgressBar1n.Value = 1000) Then
                    ProgressBar1n.Visible = False
                End If

                Main.NumericUpDown2.Visible = True
                Main.NumericUpDown2.Enabled = True
                Main.NumericUpDown1.Enabled = True
                Main.Label4.Text = "Sin<B>:"
                Main.Label6.Text = "Sin<A>:"
                Main.SideXBox.Enabled = True
                Main.SideYBox.Enabled = False
                Main.Clear.Enabled = True
            Next I
            ProgressBar1n.Value = 0
            Me.Hide()
            Label3.Text = "Ready"

            If (ColorDialog1.Color = Color.Black) Then
                Main.AnswerBox.ForeColor = Color.Black
            ElseIf (ColorDialog1.Color = Color.Yellow) Then
                Main.AnswerBox.ForeColor = Color.Yellow
            ElseIf (ColorDialog1.Color = Color.Red) Then
                Main.AnswerBox.ForeColor = Color.Red
            Else
                Main.AnswerBox.ForeColor = Color.White
            End If
        End If
    End Sub

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ProgressBar1n.Visible = False
    End Sub

    Private Sub Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint
        TableLayoutPanel2.Visible = False
    End Sub

    Private Sub SolvingBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SolvingBox.SelectedIndexChanged
        If (SolvingBox.SelectedItem = "SideX") Then
            NumericUpDown1.Value = 2
            NumericUpDown2.Value = 1
        ElseIf (SolvingBox.SelectedItem = "SideY") Then
            NumericUpDown1.Value = 2
            NumericUpDown2.Value = 1
        ElseIf (SolvingBox.SelectedItem = "AngleX") Then
            NumericUpDown1.Value = 1
            NumericUpDown2.Value = 2
        ElseIf (SolvingBox.SelectedItem = "AngleY") Then
            NumericUpDown1.Value = 1
            NumericUpDown2.Value = 2
        End If
    End Sub
End Class